home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Asm / Madness4 / Miner4.4.s < prev   
Encoding:
Text File  |  1980-11-26  |  17.1 KB  |  1,087 lines

  1. debugging    equ    0
  2.  
  3. ;Miner Madness4.
  4. ;All levels are 320*256 but you do not have to use it all!
  5. ;You draw them in Dpaint
  6. ;and my little proggy converts it to level data cool huh.
  7. ;there is a file called levelkey.iff which says what colour does what!
  8.  
  9. ;at the moment, background collision can be done on bp5
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. ;summink else is a bit fucked. FIXED 16-09-97 (bge to noswap instead of out)
  22. ;sometimes when you go up or down.
  23. ;it just sticks at a random point (always at the start if a char)
  24. ;to correct it go down or up (reverse)
  25. ;nothing seems to be corrputed but it does need fixing
  26. ;its probably just a bgt should be a bge or something
  27.  
  28. ;got rid of the glithy bits the would appear at the top and bottom,
  29. ;my origonal version had a few bug in it which meant that it was
  30. ;only doing one of the 2 things it shoulld have been doing
  31.  
  32.  
  33. ;question.
  34. ;why does the routine run every time when you go down
  35. ;but only on rare ocasions going up? FIXED 27-8-97
  36.  
  37.  
  38. ;Theres a -=>FRIG<=- its in the go_bitplanes
  39. ;when going left (with pointers set to far left)
  40. ;youd get residue blitted on the screen (dunno why!)
  41. ;so i adjusted the left to be 1word in and frigged gobitplanes...
  42.  
  43. ;edited copperlist to work of A1200
  44.     section screen,code_c        ;make sure chip ram
  45.     
  46.     opt    c+
  47.  
  48. gap    equ    640
  49. top    equ    2
  50. viswid    equ    40
  51. vishi    equ    12
  52. pagewid    equ    2+viswid+2
  53. pagehi    equ    top+vishi+top
  54. screensize    equ    gap+(pagewid*(pagehi*16)*5)+gap
  55. borderline    equ    top*16
  56. levelwid    equ    320
  57. levelhi    equ    256
  58. downstrip    equ    3    (divisible by 18) (INCREASE THIS FOR FASTER Y SPEEDS)
  59.             ;downstrip = make the horiz strips in n vblanks
  60.         
  61.  
  62.     bra    Start
  63.     
  64. showCOLL    dc.b    0    ;show only the collision copperlist
  65.     dc.b    "$VER:Madness4.4"
  66.     cnop    0,4
  67. Start
  68.     
  69.     lea    gfxname,a1
  70.     CALLEXEC    OldOpenLibrary
  71.     beq    NO_MEMORY
  72.     move.l    d0,_GfxBase
  73.  
  74.     lea    dosname,a1
  75.     CALLEXEC    OldOpenLibrary
  76.     beq    NO_MEMORY
  77.     move.l    d0,_DOSBase
  78.  
  79.     lea    intname,a1          ;
  80.     moveq    #39,d0                  ; Kickstart 3.0 or higher
  81.     CALLEXEC    OpenLibrary
  82.     move.l    d0,_IntuitionBase       ; store intuitionbase
  83.  
  84.     lea    iffname,a1
  85.     CALLEXEC    OldOpenLibrary
  86.     beq    NO_MEMORY
  87.     move.l    d0,_IFFBase
  88.  
  89.     
  90.     ifeq debugging
  91.     bsr    GetSystem        
  92.     
  93.     bsr    vblank
  94.     bsr    vblank
  95.     move.l    #new,$dff080
  96.     endc
  97.  
  98.     move.w    #$8400,$dff096
  99.  
  100.     bsr    allocscrbase
  101.     move.l    scrbase,scrother
  102.     bsr    allocscrbase
  103.  
  104.     ;allocate some memory for the level
  105.     move.l    #levelwid*levelhi*4,d0
  106.     move.l    #$10000,d1    ;memory Ill have anything please
  107.     CALLEXEC    AllocMem
  108.     move.l    d0,level
  109.  
  110.         
  111.  
  112.     bsr    go_colour    
  113.  
  114.     bsr    get_old_cop    
  115.     bsr    go_bitplanes
  116.  
  117.     bsr    load_level    
  118.     bsr    convert_level
  119.  
  120.     ;init screen bits!    
  121.     move.l    scrbase,screen1
  122.     add.l    #gap,screen1
  123.     move.l    scrother,screen2
  124.     add.l    #gap,screen2
  125.     move.l    screen1,view1
  126.     move.l    screen2,view2
  127.     
  128.     ;init level bits!
  129.     move.l    level,level1
  130.     move.l    level,level2
  131.  
  132.     
  133.     
  134.  
  135. main
  136.     ifeq debugging
  137.     bsr    vblank2
  138. ;    bsr    vblank2
  139. ;    bsr    vblank2
  140. ;    bsr    vblank2
  141. ;    bsr    vblank2
  142. ;    bsr    vblank2
  143. ;    bsr    vblank2
  144. ;    bsr    vblank2
  145. ;    bsr    vblank2
  146. ;    bsr    vblank2
  147. ;    bsr    vblank2
  148. ;    bsr    vblank2
  149. ;    bsr    vblank2
  150. ;    bsr    vblank2
  151. ;    bsr    vblank2
  152. ;    bsr    vblank2
  153.     endc
  154.     
  155. ;    move.w    #$000,$dff180
  156.  
  157.     move.w    #0,joydir
  158.     bsr    joystick
  159.  
  160.     bsr    drawing
  161.  
  162.  
  163.     clr.l    d0    ;left
  164.     move.w    joydir,d0
  165.     and.w    #%0010,d0
  166.     cmp.w    #0,d0
  167.     beq    .noleft
  168.     bsr    left
  169. .noleft
  170.  
  171.  
  172.     clr.l    d0    ;right
  173.     move.w    joydir,d0
  174.     and.w    #%0001,d0
  175.     cmp.w    #0,d0
  176.     beq    .noright
  177.     bsr    right
  178. .noright
  179.     
  180.  
  181.     clr.l    d0    ;down
  182.     move.w    joydir,d0
  183.     and.w    #%0100,d0
  184.     cmp.w    #0,d0
  185.     beq    .notdown
  186.     bsr    down
  187. .notdown
  188.     clr.l    d0    ;UP
  189.     move.w    joydir,d0
  190.     and.w    #%1000,d0
  191.     cmp.w    #0,d0
  192.     beq    .notup
  193.     bsr    up
  194. .notup
  195.  
  196.     cmp.b    #$4d,$bfec01    ;F10 flip view
  197.     bne    .notflip
  198.     move.l    view1,a0
  199.     move.l    view2,view1
  200.     move.l    a0,view2
  201.     bsr    go_bitplanes
  202.     move.l    view1,a0
  203.     move.l    view2,view1
  204.     move.l    a0,view2
  205.     move.w    #$0f00,$dff180
  206.  
  207. .notflip
  208.     bsr    go_bitplanes
  209.  
  210.     move.w    #$0,$dff180
  211.  
  212.  
  213.     
  214.     cmp.b    #$3f,$bfec01
  215.     bne    main
  216.     
  217. exit    move    #%1000000000100000,$dff096;enable sprites
  218.     
  219.     ifeq debugging    
  220.     move.l    old,$dff080    
  221.  
  222.     bsr    RestSystem
  223.  
  224.     endc
  225.         
  226.     bsr    freescrbase
  227.     move.l    scrother,scrbase
  228.     bsr    freescrbase
  229.  
  230. ;freelevelbase
  231.     move.l    #levelwid*levelhi*4,d0
  232.     move.l    level,a1
  233.     CALLEXEC    FreeMem
  234.     
  235.  
  236. NO_MEMORY
  237.     bsr    CloseLibs    ;close libs
  238.  
  239.     rts
  240.  
  241.     include    slyma/initial    ;vblank,vblank2,go_colour,allocscrbase,freescrbase,get_old_cop
  242.     include    slyma/setup.i
  243.  
  244. CloseLibs
  245.     move.l    _GfxBase,a1
  246.     cmp.l    #0,a1
  247.     beq    .hup
  248.     CALLEXEC    CloseLibrary
  249. .hup
  250.     move.l    _IFFBase,a1
  251.     cmp.l    #0,a1
  252.     beq    .hup2
  253.     CALLEXEC    CloseLibrary
  254. .hup2
  255.     move.l    _DOSBase,a1
  256.     cmp.l    #0,a1
  257.     beq    .hup3
  258.     CALLEXEC    CloseLibrary
  259. .hup3
  260.     move.l    _IntuitionBase,a1
  261.     cmp.l    #0,a1
  262.     beq    .hup4
  263.     CALLEXEC    CloseLibrary
  264. .hup4
  265.  
  266.     rts
  267.  
  268. go_bitplanes
  269.     move.w    #5-1,d7
  270.     move.l    view1,d0
  271.     add.l    #2,d0
  272.     add.l    #top*16*pagewid*5,d0
  273.     lea    bit1h,a0
  274. cloop
  275.     move.w    d0,4(a0)    ;bit1l
  276.     swap    d0
  277.     move.w    d0,(a0)    ;bit1h
  278.     swap    d0
  279.     add.l    #pagewid,d0    ;next bitplane
  280.     add.l    #8,a0    ;next copper pos.
  281.     dbra    d7,cloop
  282.     rts
  283.  
  284. convert_level    
  285.     ;this will convert the level from a ilbm to leveldata
  286.     ;and then it will free up the memory for the picture
  287.  
  288.     ;the piccy is in leveliff    
  289.     move.l    leveliff,a0        ;start of piccy
  290.     move.l    level,a1        ;actual level
  291.     
  292. ;.loopy    256 - 0
  293. ;.loopx    320/16 - 0
  294. ;.loop16    15-0
  295. ;    grab bit, create map
  296. ;    rotate
  297. ;    bra    .loop16
  298. ;    bra    .loopx
  299. ;    bra    .loopy
  300.  
  301.     lea    chardat,a3    ;what set of 4 gfx to choose from
  302.  
  303.     move.l    a0,a2
  304.     move.l    #(levelhi)-1,d7
  305. .loopy    
  306.     move.l    a2,a0
  307.  
  308.  
  309.     move.l    #(levelwid/16)-1,d6
  310. .loopx
  311.  
  312.  
  313.     move.l    #$8000,d4    ;bit pattern to get
  314.     move.l    #16-1,d5
  315. .loop16
  316.     bsr    BitToColour
  317.     move.l    #0,(a1)
  318.     move.b    (a3,d0),3(a1)
  319. ;    move.w    d0,2(a1)
  320.  
  321.     move.w    2(a1),d0    ;get data
  322. ;    mulu    #16*5*2,d0    ;get char
  323.     move.w    d0,2(a1)
  324.  
  325.     add.l    #4,a1    ;then skip the start of the next word    
  326.  
  327.     ror.l    #1,d4
  328.     dbra    d5,.loop16
  329.     
  330.      add.l    #2,a0    ;next word of pic
  331.     dbra    d6,.loopx
  332.  
  333.     add.l    #(levelwid/8)*5,a2
  334.     dbra    d7,.loopy
  335.     
  336.  
  337.  
  338.  
  339.     ;free up the iff memory now weve finished playing with it
  340.     move.l    #((levelwid/8)*5)*levelhi,d0
  341.     move.l    leveliff,a1
  342.     CALLEXEC    FreeMem
  343.  
  344.     bsr    cheat    ;this just makes it easier for me to see
  345.     
  346.  
  347.     rts
  348.  
  349. BitToColour
  350.     clr.l    d0
  351.     clr.l    d2
  352.     move.l    #5-1,d3    ;no. bitplanes
  353. .loop    
  354.     ror.l    #1,d0    ;shift buffer
  355.     clr.l    d1
  356.     move.w    (a0,d2),d1    ;get a word ILBM
  357.     and.l    d4,d1    ;kill all but bit we want
  358.     
  359.     ;do a test to see if its set!
  360.     ;if it is or bit 0
  361.     beq    .empty
  362.     
  363.     
  364.     or.l    #$10,d0    ;or it into buffer
  365.  
  366. .empty    add.l    #levelwid/8,d2    ;do next bitplane
  367.     dbra    d3,.loop
  368.     
  369.     
  370.     rts    
  371.     
  372.     
  373.     
  374. cheat    move.l    level,a0
  375.     move.l    #((levelwid)*levelhi)-1,d7
  376. .loop
  377.     clr.l    d0
  378.     
  379.     
  380.     move.w    2(a0),d0    ;get data
  381.     bsr    isedger
  382.     
  383.     bsr    dornd    ;most blocks can be 1 of 4
  384.     
  385.     mulu    #16*5*2,d0    ;get char
  386.     move.w    d0,2(a0)
  387.     add.l    #4,a0
  388.     sub.l    #1,d7
  389.     bne    .loop
  390. ;    dbra    d7,.loop
  391.     rts
  392.  
  393. dornd    ;this uses a hack to get the random number (from horiz vbeam)
  394.     ;all dirt blocks can be 1 of 4 with exception of the dirt block 1
  395.     cmp.b    #1,d0
  396.     ble    .out    ;dont rand dirt 1
  397.     cmp.b    #58,d0
  398.     bge    .out    ;all under 58 are in sets of 4
  399.     
  400.     bsr    gornd
  401.     add.b    d1,d0
  402. .out    rts
  403.  
  404. gornd
  405.     
  406.     clr.l    d1
  407.     move.w    $dff006,d1
  408.     and.l    #%00000011,d1
  409. ;    move.l    #1,d1
  410.     rts
  411.  
  412.  
  413.  
  414. isedger
  415.     ;look NESW from a0 to decide which gfk to use
  416.     ;a0 has the current char no.
  417.     ;if its 0 then try the next one.
  418.     cmp.b    #1,d0
  419.     bne    .out    ;we only want dirt
  420.     
  421.     ;okay we have found some dirt.
  422.     clr.l    d1    ;other dirt positions
  423.     cmp.l    #0,-levelwid*4(a0)
  424.     beq    .noup
  425.     ;there is dirt above me!
  426.     or.b    #UP,d1
  427. .noup
  428.     cmp.l    #0,levelwid*4(a0)
  429.     beq    .nodown
  430.     ;there is dirt below me!
  431.     or.b    #DOWN,d1
  432. .nodown
  433.     cmp.l    #0,-4(a0)
  434.     beq    .noleft
  435.     ;there is dirt to the left of me
  436.     or.b    #LEFT,d1
  437. .noleft
  438.     cmp.l    #0,4(a0)
  439.     beq    .noright
  440.     ;there is dirt to the right of me
  441.     or.b    #RIGHT,d1
  442. .noright
  443.     move.b    d1,dirtpos
  444.  
  445.     ;now do the routine to get the diagonals!
  446.  
  447.     clr.l    d1
  448.     cmp.l    #0,-(levelwid-1)*4(a0)
  449.     beq    .noul
  450.     ;there is dirt upleft me!
  451.     or.b    #UPLEFT,d1
  452. .noul
  453.     cmp.l    #0,-(levelwid+1)*4(a0)
  454.     beq    .nour
  455.     ;there is dirt upright me!
  456.     or.b    #UPRIGHT,d1
  457. .nour
  458.     cmp.l    #0,(levelwid-1)*4(a0)
  459.     beq    .nodl
  460.     ;there is dirt to down left of me
  461.     or.b    #DOWNLEFT,d1
  462. .nodl
  463.     cmp.l    #0,(levelwid+1)*4(a0)
  464.     beq    .nodr
  465.     ;there is dirt to the right of me
  466.     or.b    #DOWNRIGHT,d1
  467. .nodr
  468.     move.b    d1,dirtdiag
  469.  
  470.  
  471.  
  472.  
  473.     clr.l    d1
  474.     move.b    dirtpos,d1
  475.     
  476.     ;if dirtpos = $f then we have to look at the diagonals
  477.     cmp.b    #$f,d1
  478.     bne    .notf
  479.     
  480.     ;if dirtdiag = $f then its a solid rock block (default)
  481.     cmp.b    #$f,dirtdiag
  482.     beq    .notf
  483.     ;ok, now we have to decide which block to give it!
  484.     move.b    dirtdiag,d1
  485.  
  486.     clr.l    d0
  487.     lea    rockdiag,a3
  488.     move.b    (a3,d1),d0
  489.     bra    .out
  490.  
  491. .notf
  492.         
  493.     clr.l    d0
  494.     lea    rockdat,a3
  495.     move.b    (a3,d1),d0
  496.         
  497. .out    rts
  498.  
  499.  
  500.     
  501. drawing
  502.     ;if status=draw then draw summink!!!!!!!!!!!!
  503.     cmp.b    #DRAW,status
  504.     bne    .out
  505.  
  506.     CALLGRAF    WaitBlit
  507.     move.l    #$ffffffff,$dff044
  508.     move.w    #0,$dff064        ;mod A
  509.     move.w    #pagewid-2,$dff066    ;mod D
  510.     move.w    #$0,$dff042
  511.     move.w    #$09f0,$dff040
  512.  
  513.     
  514.     cmp.b    #pagehi/downstrip,drawcnt
  515. ;    cmp.b    #9,drawcnt
  516.     bne    .notdone
  517.     move.b    #DONE,status
  518.     bra    .out
  519. .notdone
  520.  
  521.     move.l    #downstrip-1,d6
  522.     move.l    drawscr,a3
  523.     move.l    drawlev,a4
  524.     
  525. ;    add.l    #4,a3
  526. .loopy
  527.     move.l    a3,a0
  528.     move.l    a4,a1
  529.     
  530.     move.l    #(pagewid/2)-1,d7
  531. ;    move.l    #10-1,d7
  532. .loopx
  533.  
  534.     lea    chars,a2
  535.     clr.l    d0
  536.     move.w    2(a1),d0    ;get data
  537.     add.l    d0,a2
  538.     
  539. ;    lea    chars+(16*5*2),a2
  540.     ;blit a2 onto a0
  541.     
  542.  
  543.     move.l    a2,$dff050    ;A
  544.     move.l    a0,$dff054    ;dst D    screen
  545.     move.w    #(16*5*64)+1,$dff058
  546.     
  547.     add.l    #2,a0    ;next screen pos
  548.     add.l    #4,a1    ;next level pos
  549.     
  550.     dbra    d7,.loopx
  551.     
  552.     add.l    #4*levelwid,a4
  553.     add.l    #5*(pagewid*16),a3
  554.     dbra    d6,.loopy
  555.     
  556.     add.l    #downstrip*(5*pagewid*16),drawscr
  557.     add.l    #downstrip*(4*levelwid),drawlev
  558.     
  559.     add.b    #1,drawcnt
  560.  
  561.  
  562.     
  563.     
  564. .out    rts
  565. down    
  566.     ;check to see if new level complete.!!
  567.     ;and then wait for swap
  568.     cmp.b    #borderline+borderline,flipcounter
  569.     blt    .noswap
  570.     
  571.     cmp.b    #DONE,status
  572.     beq    .noswap    ;go out until were ready!
  573.     move.b    #INIT,status
  574.     sub.b    #borderline,flipcounter
  575.     
  576.     ;swap views
  577.     move.l    view1,a0
  578.     move.l    view2,view1
  579.     move.l    a0,view2
  580.     sub.l    #(borderline)*(5*pagewid),view1
  581.     sub.l    #(borderline)*(5*pagewid),view2
  582.     
  583.     ;swap screens
  584.     move.l    screen1,a0
  585.     move.l    screen2,screen1
  586.     move.l    a0,screen2
  587.     
  588.     ;swap levels
  589.     move.l    level1,a0
  590.     move.l    level2,level1
  591.     move.l    a0,level2
  592.  
  593.     clr.l    d0
  594.     clr.l    d1
  595.     move.b    speedy,d0
  596.     move.b    speedy,d1
  597.     mulu    #pagewid*5,d0
  598.     
  599.  
  600.     add.l    d0,view1
  601.     add.l    d0,view2
  602.     add.b    d1,flipcounter
  603.  
  604.     bra    .out
  605. .noswap    
  606.     clr.l    d0
  607.     clr.l    d1
  608.     move.b    speedy,d0
  609.     move.b    speedy,d1
  610.     mulu    #pagewid*5,d0
  611.     
  612.  
  613.     add.l    d0,view1
  614.     add.l    d0,view2
  615.     add.b    d1,flipcounter
  616.     cmp.b    #borderline,flipcounter
  617.     blt    .ok
  618.     
  619. .sttsr    ;if status=draw or done then do nothing
  620.     cmp.b    #DRAW,status
  621.     beq    .noinit
  622.     
  623.     ;setup to draw the new screen!!!!
  624.     move.l    screen2,drawscr
  625.  
  626.     move.l    level1,level2    
  627.     add.l    #top*(levelwid*4),level2    ;go down 3 lines
  628.     move.l    level2,drawlev
  629.     
  630.     move.b    #DRAW,status
  631.     move.b    #0,drawcnt
  632.     bra    .ok
  633. .noinit
  634.     
  635. .ok    
  636. .out
  637. ;    bsr    go_bitplanes
  638.     rts
  639. up    
  640.     ;check to see if new level complete.!!
  641.     ;and then wait for swap
  642.     cmp.b    #0,flipcounter
  643.     bgt    .noswap
  644.     
  645.     cmp.b    #DONE,status
  646.     beq    .noswap    ;go out until were ready!
  647.     move.b    #INIT,status
  648.     add.b    #borderline,flipcounter
  649.     
  650.     ;swap views
  651.     move.l    view1,a0
  652.     move.l    view2,view1
  653.     move.l    a0,view2
  654.     add.l    #(borderline)*(5*pagewid),view1
  655.     add.l    #(borderline)*(5*pagewid),view2
  656.     
  657.     ;swap screens
  658.     move.l    screen1,a0
  659.     move.l    screen2,screen1
  660.     move.l    a0,screen2
  661.     
  662.     ;swap levels
  663.     move.l    level1,a0
  664.     move.l    level2,level1
  665.     move.l    a0,level2
  666.  
  667.     clr.l    d0
  668.     clr.l    d1
  669.     move.b    speedy,d0
  670.     move.b    speedy,d1
  671.     mulu    #pagewid*5,d0
  672.     
  673.  
  674.     sub.l    d0,view1
  675.     sub.l    d0,view2
  676.     sub.b    d1,flipcounter
  677.  
  678.     bra    .out
  679. .noswap    
  680.     clr.l    d0
  681.     clr.l    d1
  682.     move.b    speedy,d0
  683.     move.b    speedy,d1
  684.     mulu    #pagewid*5,d0
  685.     
  686.  
  687.     sub.l    d0,view1
  688.     sub.l    d0,view2
  689.     sub.b    d1,flipcounter
  690.     cmp.b    #borderline,flipcounter
  691.     bgt    .ok
  692.     
  693. .outss    ;if status=draw or done then do nothing
  694.     cmp.b    #DRAW,status
  695.     beq    .noinit
  696.     
  697.     ;setup to draw the new screen!!!!
  698.     move.l    screen2,drawscr
  699.  
  700.     move.l    level1,level2    
  701.     sub.l    #top*(levelwid*4),level2    ;go up 3 lines
  702.     move.l    level2,drawlev
  703.     
  704.     move.b    #DRAW,status
  705.     move.b    #0,drawcnt
  706.     bra    .ok
  707. .noinit
  708.     
  709. .ok    
  710. .out
  711. ;    bsr    go_bitplanes
  712.     rts
  713.  
  714. right
  715.     clr.l    d0
  716.     clr.l    d1
  717.     move.b    speedx,d0
  718.     move.b    speedx,d1
  719.     rol.l    #4,d0
  720.     or.b    speedx,d0
  721.     
  722.     
  723.     clr.l    d2
  724.     move.w    smooth,d2
  725.     sub.w    d0,d2
  726.     move.w    d2,smooth
  727. ;    sub.w    smooth,d0
  728.  
  729.     clr.l    d2
  730.     move.b    scrollx,d2
  731.     sub.b    d1,d2
  732.     move.b    d2,scrollx
  733. ;    sub.b    #3,scrollx,d1
  734.     cmp.b    #0,scrollx
  735.     bge    .out
  736.     
  737.     add.b    #16,scrollx
  738.     add.w    #$ff+$11,smooth
  739.  
  740.     ;draw on screen1+viswid
  741.     ;draw on screen2+viswid
  742.     
  743.     add.l    #2,screen1
  744.     add.l    #2,screen2
  745.     add.l    #2,view1
  746.     add.l    #2,view2
  747.     add.l    #4,level1
  748.     add.l    #4,level2
  749.     
  750.     ;first draw  on the visible screen!
  751.     move.l    level1,a1
  752.     add.l    #2*viswid,a1
  753.     
  754.     move.l    screen1,a0
  755.     add.l    #viswid,a0
  756.  
  757.     bsr    blitstrip
  758.  
  759.     ;now draw  on the second screen!
  760.     move.l    level2,a1
  761.     add.l    #2*viswid,a1
  762.     
  763.     move.l    screen2,a0
  764.     add.l    #viswid,a0
  765.  
  766.     bsr    blitstrip
  767. .out    rts
  768.  
  769. left
  770.     clr.l    d0
  771.     clr.l    d1
  772.     move.b    speedx,d0
  773.     move.b    speedx,d1
  774.     rol.l    #4,d0
  775.     or.b    speedx,d0
  776.     
  777.     
  778.     clr.l    d2
  779.     move.w    smooth,d2
  780.     add.w    d0,d2
  781.     move.w    d2,smooth
  782. ;    add.w    smooth,d0
  783.  
  784.     clr.l    d2
  785.     move.b    scrollx,d2
  786.     add.b    d1,d2
  787.     move.b    d2,scrollx
  788. ;    add.b    #3,scrollx,d1
  789.  
  790.     cmp.b    #15,scrollx
  791.     ble    .out
  792.     
  793.     sub.b    #16,scrollx
  794.     sub.w    #$ff+$11,smooth
  795.  
  796.     ;draw on screen1
  797.     ;draw on screen2
  798.     
  799.     sub.l    #2,screen1
  800.     sub.l    #2,screen2
  801.     sub.l    #2,view1
  802.     sub.l    #2,view2
  803.     sub.l    #4,level1
  804.     sub.l    #4,level2
  805.     
  806.     ;first draw  on the visible screen!
  807.     move.l    level1,a1
  808.     add.l    #4,a1
  809.     
  810.     move.l    screen1,a0
  811.     add.l    #2,a0
  812.  
  813.     bsr    blitstrip
  814.  
  815.     ;now draw  on the second screen!
  816.     move.l    level2,a1
  817.     add.l    #4,a1
  818.     
  819.     move.l    screen2,a0
  820.     add.l    #2,a0
  821.  
  822.     bsr    blitstrip
  823. .out    rts
  824.     
  825.     
  826.     
  827. blitstrip
  828.     CALLGRAF    WaitBlit
  829.     move.l    #$ffffffff,$dff044
  830.     move.w    #0,$dff064        ;mod A
  831.     move.w    #pagewid-2,$dff066    ;mod D
  832.     move.w    #$0,$dff042
  833.     move.w    #$09f0,$dff040
  834.     
  835.     move.l    #pagehi-1,d6
  836. .loopy
  837.  
  838.     lea    chars,a2
  839.     clr.l    d0
  840.     move.w    2(a1),d0    ;get data
  841.     add.l    d0,a2
  842.     
  843. ;    lea    chars+(16*5*2),a2
  844.     ;blit a2 onto a0
  845.     
  846.  
  847.     move.l    a2,$dff050    ;A
  848.     move.l    a0,$dff054    ;dst D    screen
  849.     move.w    #(16*5*64)+1,$dff058
  850.     
  851.     add.l    #4*levelwid,a1
  852.     add.l    #5*(pagewid*16),a0
  853.     dbra    d6,.loopy
  854.     
  855.  
  856.     rts
  857.     
  858. joystick
  859.     clr.l    d1
  860.     move.w    $dff00c,d0    ;$dff00a port one
  861.     btst    #9,d0
  862.     beq    .not_left
  863.     bset    #1,d1        ;left
  864. .not_left
  865.     btst    #1,d0
  866.     beq    .not_right        
  867.     bset    #0,d1        ;right
  868. .not_right
  869.     move.w    d0,d2
  870.     lsr.w    #1,d2
  871.     eor.w    d0,d2
  872.     btst    #0,d2
  873.     beq    .not_down
  874.     bset    #2,d1        ;down
  875. .not_down    btst    #8,d2
  876.     beq    .not_up
  877.     bset    #3,d1        ;up
  878. .not_up    
  879.     move.l    d1,d0        ;save in d0
  880.     
  881.     move.w    d0,joydir
  882.  
  883.     rts
  884.  
  885. load_level
  886.     ;load in the level as ILBM
  887.     ;NOTE the convert level routine will free up the ilbm pic
  888.  
  889.  
  890.     ;This is an IFF piccy.
  891.     ;We want a bitmap one please so lets use the iff library to load
  892.     
  893.     lea    levname,a0    
  894.     move.l    #IFFL_MODE_READ,d0
  895.     CALLIFF    OpenIFF
  896.     move.l    d0,iffhandle
  897.     
  898.     lea    bitmap,a0
  899.     move.l    #$05,d0        ;depth
  900.     move.l    #levelwid*5,d1        ;width
  901.     move.l    #levelhi,d2        ;height
  902.     CALLGRAF    InitBitMap
  903.  
  904.     ;allocate some memory for the picture
  905.     clr.l    d0        ;allocate some memory for it!
  906.     move.l    #((levelwid/8)*5)*levelhi,d0
  907.     move.l    #MEMF_CLEAR,d1
  908.     CALLEXEC    AllocMem
  909.     move.l    d0,leveliff
  910.     
  911.     ;now copy the pointer into the bitmap structure
  912.     move.l    #5-1,d7
  913.     move.l    leveliff,a0
  914.     lea    bitmap,a1
  915. .back    move.l    a0,bm_Planes(a1)
  916.     add.l    #40,a0
  917.     add.l    #4,a1    ;next long please
  918.     dbra    d7,.back
  919.     
  920.  
  921.     move.l    iffhandle,a1
  922.     lea    bitmap,a0
  923.     CALLIFF    DecodePic
  924.     
  925.     move.l    iffhandle,a1
  926.     CALLIFF    CloseIFF    
  927.     
  928.     
  929.     rts
  930.  
  931.     rts
  932.  
  933.  
  934.  
  935.     
  936.  
  937.     even
  938.     cnop    0,4    
  939. new:
  940.     dc.w    bpl1mod
  941.     dc.w    (pagewid*5)-viswid
  942.     dc.w    bpl2mod
  943.     dc.w    (pagewid*5)-viswid
  944.     dc.w    dmacon,$0020
  945. scnposs    dc.w    diwstrt,$2c91
  946. scnpose    dc.w    diwstop,$2cb1 
  947.     dc.w    ddfstrt,$38
  948.     dc.w    ddfstop,$d0
  949.     dc.w    bplcon0,$5200
  950.     dc.w    bplcon1
  951. smooth    dc.w    0
  952.     dc.w    bplcon2,0
  953.     dc.w    bplcon3,$0c00    ;bplcon3
  954.     dc.w    bpl1h
  955. bit1h    dc.w    0
  956.     dc.w    bpl1l
  957. bit1l    dc.w    0
  958.     dc.w    bpl2h
  959. bit2h    dc.w    0
  960.     dc.w    bpl2l
  961. bit2l    dc.w    0
  962.     dc.w    bpl3h
  963. bit3h    dc.w    0
  964.     dc.w    bpl3l
  965. bit3l    dc.w    0
  966.     dc.w    bpl4h
  967. bit4h    dc.w    0
  968.     dc.w    bpl4l
  969. bit4l    dc.w    0
  970.     dc.w    bpl5h
  971. bit5h    dc.w    0
  972.     dc.w    bpl5l
  973. bit5l    dc.w    0
  974.  
  975. colour    include    slyma/colclist
  976.     dc.l    $5009fffe
  977.     dc.w    bplcon0,$5200
  978.  
  979.     dc.l    $db09fffe
  980.     dc.l    $018000f0
  981.     dc.w    bplcon0,$0200
  982.     dc.l    $dc09fffe
  983. ;    dc.l    $01800000
  984.     dc.w    $009c,$8010
  985.  
  986.     
  987.     dc.w    $ffff,$fffe        ;end of coper list
  988.  
  989.     dc.l    0
  990. old    dc.l    0
  991. gfxname    dc.b    "graphics.library",0
  992. intname    dc.b    "intuition.library",0
  993. dosname    dc.b    "dos.library",0
  994. iffname    dc.b    "iff.library",0
  995.  
  996. wbname          dc.b  "Workbench",0
  997.     even
  998.     dc.l    0
  999.  
  1000. _IFFBase    dc.l    0
  1001. _DOSBase    dc.l    0
  1002. _GfxBase    dc.l    0
  1003. _IntuitionBase    dc.l    0
  1004. scrbase    dc.l    0    ;pointer to screen area!
  1005. scrother    dc.l    0    ;pointer to 2nd screen!
  1006.  
  1007. screen1    dc.l    0    ;location of screen1
  1008. screen2    dc.l    0    ;location of screen2
  1009. level1    dc.l    0    ;level pos on screen1
  1010. level2    dc.l    0    ;level pos on screen2
  1011. view1    dc.l    0    ;what you see! screen1
  1012. view2    dc.l    0    ;what you see! screen2
  1013.  
  1014. leveliff    dc.l    0    ;this is a pointer to the iff level
  1015.  
  1016. drawlev    dc.l    0    ;draw level pointer
  1017. drawscr    dc.l    0    ;darw screnn pointer
  1018.  
  1019. taglist         dc.l  VTAG_SPRITERESN_GET
  1020. resolution      dc.l  SPRITERESN_ECS
  1021.                 dc.l  TAG_DONE,0
  1022.  
  1023. wbview          dc.l  0
  1024. oldres          dc.l  0
  1025. wbscreen        dc.l  0
  1026. oldpri    dc.l    0
  1027.  
  1028. iffhandle    dc.l    0    ;iff handle
  1029. bitmap
  1030.     dcb.l    40
  1031.  
  1032.     even
  1033.     cnop    0,4
  1034. chardat    ;this is to decide what gfk to use +(rnd 0-3)
  1035.     ;colour 1 = 1(solid rock) not edge
  1036.     ;colour 2 = 50(grass)
  1037.     dc.b    0,1,50
  1038.  
  1039.  
  1040.     ;this is for the isedger prg whih will decide which rock to use
  1041.     ;dir (rockdat,dirtpos)=charno.
  1042. rockdat    dc.b    54,02,02,02,14,34,46,02,14
  1043.     dc.b    38,42,10,14,06,14,01
  1044. rockdiag    dc.b    01,01,01,01,01,01,01,30,01
  1045.     dc.b    01,01,18,01,22,26,01,01,01    
  1046.     even
  1047.     cnop    0,4
  1048.  
  1049.  
  1050. joydir    dc.w    0    ;direction from mr joystick
  1051.  
  1052. status    dc.b    0    ;what am i doing
  1053. flipcounter    dc.b    borderline
  1054. drawcnt    dc.b    0    
  1055. scrollx    dc.b    0
  1056.  
  1057. speedx    dc.b    4
  1058. speedy    dc.b    4
  1059.  
  1060. dirtpos    dc.b    0    ;direction of dirt in isedger (level creation)
  1061. dirtdiag    dc.b    0    ;as above but diagonally
  1062.  
  1063. INIT    equ    0    ;setting up to draw
  1064. DRAW    equ    1    ;drawing
  1065. DONE    equ    2    ;finished drawing ready to swap
  1066.  
  1067. levname    dc.b    "grafix/level.iff",0
  1068.  
  1069. UP    equ    8
  1070. DOWN    equ    4
  1071. LEFT    equ    2
  1072. RIGHT    equ    1
  1073.  
  1074. UPLEFT    equ    8
  1075. UPRIGHT    equ    4
  1076. DOWNLEFT    equ    2
  1077. DOWNRIGHT    equ    1
  1078.  
  1079.     even
  1080.     cnop    0,4
  1081. level    dc.l    0
  1082. ;dcb.b    ((levelwid)*(levelhi+2))*4    ;*4 for long
  1083. chars    incbin    grafix/REWGRND.gfx
  1084. colours    incbin    grafix/REWGRND.GFX.Cmap
  1085.     dcb.w    32,0
  1086.  
  1087.